.class public Lorg/microemu/android/device/AndroidInputMethod;
.super Lorg/microemu/device/InputMethod;
.source "AndroidInputMethod.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lorg/microemu/android/device/AndroidInputMethod$KeyReleasedDelayTask;
    }
.end annotation


# instance fields
.field private eventAlreadyConsumed:Z

.field private keyReleasedDelayTimer:Ljava/util/Timer;

.field private repeatModeKeyCodes:Ljava/util/List;


# direct methods
.method public constructor <init>()V
    .locals 1

    .prologue
    .line 81
    invoke-direct {p0}, Lorg/microemu/device/InputMethod;-><init>()V

    .line 51
    new-instance v0, Ljava/util/Vector;

    invoke-direct {v0}, Ljava/util/Vector;-><init>()V

    iput-object v0, p0, Lorg/microemu/android/device/AndroidInputMethod;->repeatModeKeyCodes:Ljava/util/List;

    .line 82
    const-string v0, "InputKeyReleasedDelayTimer"

    invoke-static {v0}, Lorg/microemu/util/ThreadUtils;->createTimer(Ljava/lang/String;)Ljava/util/Timer;

    move-result-object v0

    iput-object v0, p0, Lorg/microemu/android/device/AndroidInputMethod;->keyReleasedDelayTimer:Ljava/util/Timer;

    .line 83
    return-void
.end method

.method static synthetic access$002(Lorg/microemu/android/device/AndroidInputMethod;Z)Z
    .locals 0
    .parameter "x0"
    .parameter "x1"

    .prologue
    .line 45
    iput-boolean p1, p0, Lorg/microemu/android/device/AndroidInputMethod;->eventAlreadyConsumed:Z

    return p1
.end method

.method private getKeyCode(Landroid/view/KeyEvent;)I
    .locals 2
    .parameter "keyEvent"

    .prologue
    .line 336
    invoke-virtual {p1}, Landroid/view/KeyEvent;->getKeyCode()I

    move-result v0

    .line 339
    .local v0, deviceKeyCode:I
    sparse-switch v0, :sswitch_data_0

    .line 359
    invoke-virtual {p1}, Landroid/view/KeyEvent;->getUnicodeChar()I

    move-result v1

    .line 360
    .local v1, resultKeyCode:I
    if-nez v1, :cond_0

    .line 361
    neg-int v1, v0

    .line 365
    :cond_0
    :goto_0
    return v1

    .line 341
    .end local v1           #resultKeyCode:I
    :sswitch_0
    const/16 v1, 0x8

    .line 342
    .restart local v1       #resultKeyCode:I
    goto :goto_0

    .line 344
    .end local v1           #resultKeyCode:I
    :sswitch_1
    const/4 v1, 0x1

    .line 345
    .restart local v1       #resultKeyCode:I
    goto :goto_0

    .line 347
    .end local v1           #resultKeyCode:I
    :sswitch_2
    const/4 v1, 0x6

    .line 348
    .restart local v1       #resultKeyCode:I
    goto :goto_0

    .line 350
    .end local v1           #resultKeyCode:I
    :sswitch_3
    const/4 v1, 0x2

    .line 351
    .restart local v1       #resultKeyCode:I
    goto :goto_0

    .line 353
    .end local v1           #resultKeyCode:I
    :sswitch_4
    const/4 v1, 0x5

    .line 354
    .restart local v1       #resultKeyCode:I
    goto :goto_0

    .line 356
    .end local v1           #resultKeyCode:I
    :sswitch_5
    const/16 v1, 0x7f

    .line 357
    .restart local v1       #resultKeyCode:I
    goto :goto_0

    .line 339
    nop

    :sswitch_data_0
    .sparse-switch
        0x13 -> :sswitch_1
        0x14 -> :sswitch_2
        0x15 -> :sswitch_3
        0x16 -> :sswitch_4
        0x17 -> :sswitch_0
        0x43 -> :sswitch_5
    .end sparse-switch
.end method


# virtual methods
.method public buttonPressed(Landroid/view/KeyEvent;)V
    .locals 6
    .parameter "keyEvent"

    .prologue
    const/4 v5, 0x1

    .line 86
    const/4 v2, 0x0

    iput-boolean v2, p0, Lorg/microemu/android/device/AndroidInputMethod;->eventAlreadyConsumed:Z

    .line 87
    invoke-static {}, Lorg/microemu/device/DeviceFactory;->getDevice()Lorg/microemu/device/Device;

    move-result-object v2

    invoke-interface {v2}, Lorg/microemu/device/Device;->hasRepeatEvents()Z

    move-result v2

    if-eqz v2, :cond_3

    iget-object v2, p0, Lorg/microemu/android/device/AndroidInputMethod;->inputMethodListener:Lorg/microemu/device/InputMethodListener;

    if-nez v2, :cond_3

    .line 88
    iget-object v2, p0, Lorg/microemu/android/device/AndroidInputMethod;->repeatModeKeyCodes:Ljava/util/List;

    new-instance v3, Ljava/lang/Integer;

    invoke-direct {p0, p1}, Lorg/microemu/android/device/AndroidInputMethod;->getKeyCode(Landroid/view/KeyEvent;)I

    move-result v4

    invoke-direct {v3, v4}, Ljava/lang/Integer;-><init>(I)V

    invoke-interface {v2, v3}, Ljava/util/List;->contains(Ljava/lang/Object;)Z

    move-result v2

    if-eqz v2, :cond_2

    .line 89
    invoke-static {}, Lorg/microemu/MIDletBridge;->getMIDletAccess()Lorg/microemu/MIDletAccess;

    move-result-object v1

    .line 90
    .local v1, ma:Lorg/microemu/MIDletAccess;
    if-nez v1, :cond_1

    .line 121
    .end local v1           #ma:Lorg/microemu/MIDletAccess;
    :cond_0
    :goto_0
    return-void

    .line 93
    .restart local v1       #ma:Lorg/microemu/MIDletAccess;
    :cond_1
    invoke-virtual {v1}, Lorg/microemu/MIDletAccess;->getDisplayAccess()Lorg/microemu/DisplayAccess;

    move-result-object v0

    .line 94
    .local v0, da:Lorg/microemu/DisplayAccess;
    if-eqz v0, :cond_0

    .line 97
    invoke-direct {p0, p1}, Lorg/microemu/android/device/AndroidInputMethod;->getKeyCode(Landroid/view/KeyEvent;)I

    move-result v2

    invoke-interface {v0, v2}, Lorg/microemu/DisplayAccess;->keyRepeated(I)V

    .line 98
    iput-boolean v5, p0, Lorg/microemu/android/device/AndroidInputMethod;->eventAlreadyConsumed:Z

    goto :goto_0

    .line 101
    .end local v1           #ma:Lorg/microemu/MIDletAccess;
    .end local v0           #da:Lorg/microemu/DisplayAccess;
    :cond_2
    iget-object v2, p0, Lorg/microemu/android/device/AndroidInputMethod;->repeatModeKeyCodes:Ljava/util/List;

    new-instance v3, Ljava/lang/Integer;

    invoke-direct {p0, p1}, Lorg/microemu/android/device/AndroidInputMethod;->getKeyCode(Landroid/view/KeyEvent;)I

    move-result v4

    invoke-direct {v3, v4}, Ljava/lang/Integer;-><init>(I)V

    invoke-interface {v2, v3}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 117
    :cond_3
    invoke-virtual {p0, p1}, Lorg/microemu/android/device/AndroidInputMethod;->fireInputMethodListener(Landroid/view/KeyEvent;)Z

    move-result v2

    if-eqz v2, :cond_0

    .line 118
    iput-boolean v5, p0, Lorg/microemu/android/device/AndroidInputMethod;->eventAlreadyConsumed:Z

    goto :goto_0
.end method

.method public buttonReleased(Landroid/view/KeyEvent;)V
    .locals 6
    .parameter "keyEvent"

    .prologue
    .line 124
    invoke-static {}, Lorg/microemu/device/DeviceFactory;->getDevice()Lorg/microemu/device/Device;

    move-result-object v2

    invoke-interface {v2}, Lorg/microemu/device/Device;->hasRepeatEvents()Z

    move-result v2

    if-eqz v2, :cond_1

    iget-object v2, p0, Lorg/microemu/android/device/AndroidInputMethod;->inputMethodListener:Lorg/microemu/device/InputMethodListener;

    if-nez v2, :cond_1

    .line 125
    iget-object v2, p0, Lorg/microemu/android/device/AndroidInputMethod;->repeatModeKeyCodes:Ljava/util/List;

    new-instance v3, Ljava/lang/Integer;

    invoke-direct {p0, p1}, Lorg/microemu/android/device/AndroidInputMethod;->getKeyCode(Landroid/view/KeyEvent;)I

    move-result v4

    invoke-direct {v3, v4}, Ljava/lang/Integer;-><init>(I)V

    invoke-interface {v2, v3}, Ljava/util/List;->remove(Ljava/lang/Object;)Z

    .line 126
    iget-object v2, p0, Lorg/microemu/android/device/AndroidInputMethod;->keyReleasedDelayTimer:Ljava/util/Timer;

    new-instance v3, Lorg/microemu/android/device/AndroidInputMethod$KeyReleasedDelayTask;

    invoke-direct {p0, p1}, Lorg/microemu/android/device/AndroidInputMethod;->getKeyCode(Landroid/view/KeyEvent;)I

    move-result v4

    invoke-direct {v3, p0, v4}, Lorg/microemu/android/device/AndroidInputMethod$KeyReleasedDelayTask;-><init>(Lorg/microemu/android/device/AndroidInputMethod;I)V

    const-wide/16 v4, 0x32

    invoke-virtual {v2, v3, v4, v5}, Ljava/util/Timer;->schedule(Ljava/util/TimerTask;J)V

    .line 141
    :cond_0
    :goto_0
    return-void

    .line 128
    :cond_1
    invoke-static {}, Lorg/microemu/MIDletBridge;->getMIDletAccess()Lorg/microemu/MIDletAccess;

    move-result-object v1

    .line 129
    .local v1, ma:Lorg/microemu/MIDletAccess;
    if-eqz v1, :cond_0

    .line 133
    invoke-virtual {v1}, Lorg/microemu/MIDletAccess;->getDisplayAccess()Lorg/microemu/DisplayAccess;

    move-result-object v0

    .line 134
    .local v0, da:Lorg/microemu/DisplayAccess;
    if-eqz v0, :cond_0

    .line 138
    invoke-direct {p0, p1}, Lorg/microemu/android/device/AndroidInputMethod;->getKeyCode(Landroid/view/KeyEvent;)I

    move-result v2

    invoke-interface {v0, v2}, Lorg/microemu/DisplayAccess;->keyReleased(I)V

    .line 139
    const/4 v2, 0x0

    iput-boolean v2, p0, Lorg/microemu/android/device/AndroidInputMethod;->eventAlreadyConsumed:Z

    goto :goto_0
.end method

.method public dispose()V
    .locals 0

    .prologue
    .line 372
    return-void
.end method

.method protected fireInputMethodListener(Landroid/view/KeyEvent;)Z
    .locals 4
    .parameter "keyEvent"

    .prologue
    const/4 v3, 0x0

    .line 162
    invoke-static {}, Lorg/microemu/MIDletBridge;->getMIDletAccess()Lorg/microemu/MIDletAccess;

    move-result-object v1

    .line 163
    .local v1, ma:Lorg/microemu/MIDletAccess;
    if-nez v1, :cond_0

    move v2, v3

    .line 331
    :goto_0
    return v2

    .line 166
    :cond_0
    invoke-virtual {v1}, Lorg/microemu/MIDletAccess;->getDisplayAccess()Lorg/microemu/DisplayAccess;

    move-result-object v0

    .line 167
    .local v0, da:Lorg/microemu/DisplayAccess;
    if-nez v0, :cond_1

    move v2, v3

    .line 168
    goto :goto_0

    .line 171
    :cond_1
    iget-object v2, p0, Lorg/microemu/android/device/AndroidInputMethod;->inputMethodListener:Lorg/microemu/device/InputMethodListener;

    if-nez v2, :cond_2

    .line 172
    invoke-direct {p0, p1}, Lorg/microemu/android/device/AndroidInputMethod;->getKeyCode(Landroid/view/KeyEvent;)I

    move-result v2

    invoke-interface {v0, v2}, Lorg/microemu/DisplayAccess;->keyPressed(I)V

    .line 173
    const/4 v2, 0x1

    goto :goto_0

    :cond_2
    move v2, v3

    .line 331
    goto :goto_0
.end method

.method public getGameAction(I)I
    .locals 1
    .parameter "keyCode"

    .prologue
    .line 378
    packed-switch p1, :pswitch_data_0

    .line 395
    :pswitch_0
    const/4 v0, 0x0

    .line 398
    .local v0, gameAction:I
    :goto_0
    return v0

    .line 380
    .end local v0           #gameAction:I
    :pswitch_1
    const/16 v0, 0x8

    .line 381
    .restart local v0       #gameAction:I
    goto :goto_0

    .line 383
    .end local v0           #gameAction:I
    :pswitch_2
    const/4 v0, 0x1

    .line 384
    .restart local v0       #gameAction:I
    goto :goto_0

    .line 386
    .end local v0           #gameAction:I
    :pswitch_3
    const/4 v0, 0x6

    .line 387
    .restart local v0       #gameAction:I
    goto :goto_0

    .line 389
    .end local v0           #gameAction:I
    :pswitch_4
    const/4 v0, 0x2

    .line 390
    .restart local v0       #gameAction:I
    goto :goto_0

    .line 392
    .end local v0           #gameAction:I
    :pswitch_5
    const/4 v0, 0x5

    .line 393
    .restart local v0       #gameAction:I
    goto :goto_0

    .line 378
    :pswitch_data_0
    .packed-switch 0x1
        :pswitch_2
        :pswitch_4
        :pswitch_0
        :pswitch_0
        :pswitch_5
        :pswitch_3
        :pswitch_0
        :pswitch_1
    .end packed-switch
.end method

.method public getKeyCode(I)I
    .locals 2
    .parameter "gameAction"

    .prologue
    .line 404
    packed-switch p1, :pswitch_data_0

    .line 433
    :pswitch_0
    new-instance v1, Ljava/lang/IllegalArgumentException;

    invoke-direct {v1}, Ljava/lang/IllegalArgumentException;-><init>()V

    throw v1

    .line 406
    :pswitch_1
    const/16 v0, 0x8

    .line 436
    .local v0, keyCode:I
    :goto_0
    return v0

    .line 409
    .end local v0           #keyCode:I
    :pswitch_2
    const/4 v0, 0x1

    .line 410
    .restart local v0       #keyCode:I
    goto :goto_0

    .line 412
    .end local v0           #keyCode:I
    :pswitch_3
    const/4 v0, 0x6

    .line 413
    .restart local v0       #keyCode:I
    goto :goto_0

    .line 415
    .end local v0           #keyCode:I
    :pswitch_4
    const/4 v0, 0x2

    .line 416
    .restart local v0       #keyCode:I
    goto :goto_0

    .line 418
    .end local v0           #keyCode:I
    :pswitch_5
    const/4 v0, 0x5

    .line 419
    .restart local v0       #keyCode:I
    goto :goto_0

    .line 421
    .end local v0           #keyCode:I
    :pswitch_6
    const/16 v0, 0x9

    .line 422
    .restart local v0       #keyCode:I
    goto :goto_0

    .line 424
    .end local v0           #keyCode:I
    :pswitch_7
    const/16 v0, 0xa

    .line 425
    .restart local v0       #keyCode:I
    goto :goto_0

    .line 427
    .end local v0           #keyCode:I
    :pswitch_8
    const/16 v0, 0xb

    .line 428
    .restart local v0       #keyCode:I
    goto :goto_0

    .line 430
    .end local v0           #keyCode:I
    :pswitch_9
    const/16 v0, 0xc

    .line 431
    .restart local v0       #keyCode:I
    goto :goto_0

    .line 404
    :pswitch_data_0
    .packed-switch 0x1
        :pswitch_2
        :pswitch_4
        :pswitch_0
        :pswitch_0
        :pswitch_5
        :pswitch_3
        :pswitch_0
        :pswitch_1
        :pswitch_6
        :pswitch_7
        :pswitch_8
        :pswitch_9
    .end packed-switch
.end method

.method public getKeyName(I)Ljava/lang/String;
    .locals 2
    .parameter "keyCode"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/IllegalArgumentException;
        }
    .end annotation

    .prologue
    .line 443
    packed-switch p1, :pswitch_data_0

    .line 472
    :pswitch_0
    int-to-char v1, p1

    invoke-static {v1}, Ljava/lang/Character;->toString(C)Ljava/lang/String;

    move-result-object v0

    .line 475
    .local v0, keyName:Ljava/lang/String;
    :goto_0
    return-object v0

    .line 445
    .end local v0           #keyName:Ljava/lang/String;
    :pswitch_1
    const-string v0, "FIRE"

    .line 446
    .restart local v0       #keyName:Ljava/lang/String;
    goto :goto_0

    .line 448
    .end local v0           #keyName:Ljava/lang/String;
    :pswitch_2
    const-string v0, "UP"

    .line 449
    .restart local v0       #keyName:Ljava/lang/String;
    goto :goto_0

    .line 451
    .end local v0           #keyName:Ljava/lang/String;
    :pswitch_3
    const-string v0, "DOWN"

    .line 452
    .restart local v0       #keyName:Ljava/lang/String;
    goto :goto_0

    .line 454
    .end local v0           #keyName:Ljava/lang/String;
    :pswitch_4
    const-string v0, "LEFT"

    .line 455
    .restart local v0       #keyName:Ljava/lang/String;
    goto :goto_0

    .line 457
    .end local v0           #keyName:Ljava/lang/String;
    :pswitch_5
    const-string v0, "RIGHT"

    .line 458
    .restart local v0       #keyName:Ljava/lang/String;
    goto :goto_0

    .line 460
    .end local v0           #keyName:Ljava/lang/String;
    :pswitch_6
    const-string v0, "GAME_A"

    .line 461
    .restart local v0       #keyName:Ljava/lang/String;
    goto :goto_0

    .line 463
    .end local v0           #keyName:Ljava/lang/String;
    :pswitch_7
    const-string v0, "GAME_B"

    .line 464
    .restart local v0       #keyName:Ljava/lang/String;
    goto :goto_0

    .line 466
    .end local v0           #keyName:Ljava/lang/String;
    :pswitch_8
    const-string v0, "GAME_C"

    .line 467
    .restart local v0       #keyName:Ljava/lang/String;
    goto :goto_0

    .line 469
    .end local v0           #keyName:Ljava/lang/String;
    :pswitch_9
    const-string v0, "GAME_D"

    .line 470
    .restart local v0       #keyName:Ljava/lang/String;
    goto :goto_0

    .line 443
    :pswitch_data_0
    .packed-switch 0x1
        :pswitch_2
        :pswitch_4
        :pswitch_0
        :pswitch_0
        :pswitch_5
        :pswitch_3
        :pswitch_0
        :pswitch_1
        :pswitch_6
        :pswitch_7
        :pswitch_8
        :pswitch_9
    .end packed-switch
.end method

.method public pointerDragged(II)V
    .locals 1
    .parameter "x"
    .parameter "y"

    .prologue
    .line 156
    invoke-static {}, Lorg/microemu/device/DeviceFactory;->getDevice()Lorg/microemu/device/Device;

    move-result-object v0

    invoke-interface {v0}, Lorg/microemu/device/Device;->hasPointerMotionEvents()Z

    move-result v0

    if-eqz v0, :cond_0

    .line 157
    invoke-static {}, Lorg/microemu/MIDletBridge;->getMIDletAccess()Lorg/microemu/MIDletAccess;

    move-result-object v0

    invoke-virtual {v0}, Lorg/microemu/MIDletAccess;->getDisplayAccess()Lorg/microemu/DisplayAccess;

    move-result-object v0

    invoke-interface {v0, p1, p2}, Lorg/microemu/DisplayAccess;->pointerDragged(II)V

    .line 159
    :cond_0
    return-void
.end method

.method public pointerPressed(II)V
    .locals 1
    .parameter "x"
    .parameter "y"

    .prologue
    .line 144
    invoke-static {}, Lorg/microemu/device/DeviceFactory;->getDevice()Lorg/microemu/device/Device;

    move-result-object v0

    invoke-interface {v0}, Lorg/microemu/device/Device;->hasPointerEvents()Z

    move-result v0

    if-eqz v0, :cond_0

    .line 145
    invoke-static {}, Lorg/microemu/MIDletBridge;->getMIDletAccess()Lorg/microemu/MIDletAccess;

    move-result-object v0

    invoke-virtual {v0}, Lorg/microemu/MIDletAccess;->getDisplayAccess()Lorg/microemu/DisplayAccess;

    move-result-object v0

    invoke-interface {v0, p1, p2}, Lorg/microemu/DisplayAccess;->pointerPressed(II)V

    .line 147
    :cond_0
    return-void
.end method

.method public pointerReleased(II)V
    .locals 1
    .parameter "x"
    .parameter "y"

    .prologue
    .line 150
    invoke-static {}, Lorg/microemu/device/DeviceFactory;->getDevice()Lorg/microemu/device/Device;

    move-result-object v0

    invoke-interface {v0}, Lorg/microemu/device/Device;->hasPointerEvents()Z

    move-result v0

    if-eqz v0, :cond_0

    .line 151
    invoke-static {}, Lorg/microemu/MIDletBridge;->getMIDletAccess()Lorg/microemu/MIDletAccess;

    move-result-object v0

    invoke-virtual {v0}, Lorg/microemu/MIDletAccess;->getDisplayAccess()Lorg/microemu/DisplayAccess;

    move-result-object v0

    invoke-interface {v0, p1, p2}, Lorg/microemu/DisplayAccess;->pointerReleased(II)V

    .line 153
    :cond_0
    return-void
.end method
